home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / nwlib15.zip / DEMO.ZIP / USERSTAT.PAS < prev   
Pascal/Delphi Source File  |  1996-06-08  |  4KB  |  140 lines

  1. unit Userstat;
  2.  
  3. interface
  4.  
  5. uses 
  6.      SysUtils,
  7.      WinTypes, 
  8.      WinProcs, 
  9.      Classes, 
  10.      Graphics, 
  11.      Forms, 
  12.      Controls, 
  13.      Buttons,
  14.      StdCtrls, 
  15.      ExtCtrls,
  16.      NWLib, 
  17.      NWTools, 
  18.      NWServer; 
  19.  
  20. type
  21.   TwinUserStats = class(TForm)
  22.     CancelBtn: TBitBtn;
  23.     Bevel1: TBevel;
  24.     Label1: TLabel;
  25.     Label3: TLabel;
  26.     Label4: TLabel;
  27.     Label5: TLabel;
  28.     netName: TEdit;
  29.     fullUserName: TEdit;
  30.     netAddrs: TComboBox;
  31.     stationAddrs: TComboBox;
  32.     StatTimer: TTimer;
  33.     bPause: TBitBtn;
  34.     NWLib1: TNWLib;
  35.     NWTools1: TNWTools;
  36.     NWServer1: TNWServer;
  37.     net4Info: TGroupBox;
  38.     Label6: TLabel;
  39.     Label7: TLabel;
  40.     Label8: TLabel;
  41.     Label9: TLabel;
  42.     Label10: TLabel;
  43.     bytesRead: TEdit;
  44.     bytesWritten: TEdit;
  45.     Requests: TEdit;
  46.     recordLocks: TEdit;
  47.     fileLocks: TEdit;
  48.     Label2: TLabel;
  49.     loginTime: TEdit;
  50.     procedure bPauseClick(Sender: TObject);
  51.     procedure StatTimerTimer(Sender: TObject);
  52.     procedure FormShow(Sender: TObject);
  53.   private
  54.     { Private declarations }
  55.   public
  56.     { Public declarations }
  57.     procedure statsUpdate ;
  58.   end;
  59.  
  60. var
  61.   winUserStats: TwinUserStats;
  62.  
  63. implementation
  64.  
  65. {$R *.DFM}
  66.  
  67. procedure TwinUserStats.FormShow(Sender: TObject);
  68.   var
  69.     connectInfo : TNWConnectInfo ;    { our interface structure }
  70.     connList    : TConnList      ;
  71.     nConns      : word           ;
  72.     nLoop       : word           ;
  73.   begin
  74.     {Get User's Login Connection List, then look at on each one }
  75.     nConns := 0 ;
  76.     GetUserConnList(GetPrimaryServerID,netName.text,nConns,connList) ;
  77.     for nloop := 1 to nConns do begin
  78.       if GetConnectInfo(GetPrimaryServerID, 
  79.                         connList[nloop-1],connectInfo) then
  80.         begin
  81.           fullUserName.text := fullName(0,netname.text) + ' @ ' +
  82.                                connectInfo.serverName ;
  83.           { Add Items to ComboBoxes }
  84.           netAddrs.items.add(connectInfo.internet) ;
  85.           stationAddrs.items.add(intToStr(connList[nloop-1])) ;
  86.         end;
  87.     end;
  88.     loginTime.text    := dateTimeToStr(connectInfo.loginDateTime)  ;
  89.     netAddrs.text     := netaddrs.items[0] ;
  90.     stationAddrs.text := stationAddrs.items[0] ;
  91.     { if only one item, change combobox style }
  92.     if (netAddrs.items.count < 2) then
  93.       netAddrs.style := csSimple ;
  94.     if (stationAddrs.items.count < 2) then
  95.       stationAddrs.style := csSimple ;
  96.  
  97.     { initial timer event }
  98.     statsUpdate ;
  99.   end;
  100.  
  101. procedure TwinUserStats.bPauseClick(Sender: TObject);
  102.   begin
  103.     statTimer.enabled := (not statTimer.enabled) ;
  104.     if not statTimer.enabled then
  105.       bPause.caption := '&Resume' 
  106.     else
  107.       bPause.caption := '&Pause' ; 
  108.   end;
  109.  
  110. procedure TwinUserStats.StatTimerTimer(Sender: TObject);
  111.   begin
  112.     statsUpdate ;
  113.   end;
  114.  
  115. procedure TWinUserStats.statsUpdate ;
  116.   var
  117.     connStats : TNWConnStats ;      { public netware struct. }
  118.   begin
  119.     if getUserStats(GetPrimaryServerID,
  120.                     strToIntDef(stationAddrs.items[maxLong(stationAddrs.itemIndex,0)],0),
  121.                     connStats) then 
  122.       begin
  123.         bytesRead.text    := intToStr(connStats.bytesRead)     ;
  124.         bytesWritten.text := intToStr(connStats.bytesWritten)  ;
  125.         requests.text     := intToStr(connStats.totalRequests) ;
  126.         recordLocks.text  := intToStr(connStats.recordLocks)   ;
  127.         fileLocks.text    := intToStr(connStats.fileLocks)     ;
  128.       end                              
  129.     else
  130.       begin
  131.         bytesRead.text    := '0' ;
  132.         bytesWritten.text := '0' ;
  133.         requests.text     := '0' ;
  134.         recordLocks.text  := '0' ;
  135.         fileLocks.text    := '0' ;
  136.       end;                   
  137.   end;
  138.  
  139. end.
  140.